-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tap on Backgrounds for DateEvents and AllDayEvents #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply, and thanks already for your work! I've added some comments (sorry for the amount; some of it is just about formatting).
- I like
onBackgroundTap
, which makes clear that you can also use that listener for other purposes. We can probably merge both parameters of theTimetable
widget into a single one, which was the idea behind the additional boolean parameter (true
if the tap was in the header area,false
if the tap occurred in the part-day area). - I think I found the reason for the
+ 1
: It might be from the conversion betweenLocalDateTime
from time_machine and Dart'sDateTime
:DateTime
by default uses the local timezone, whereasLocalDateTime
has no knowledge about timezones at all. See my inline comment for an idea of how to fix it. - It sounds like a conversion problem as well, which would also explain the 23:00:00. See my inline comment for more details.
- That would be the comments about extracting lambdas into private helper methods, but otherwise, your code looks good!
Thanks for your detailed feedback Jonas.
From my feeling I'd say there is a more elegant way. I'm not quite sure about this but it works for now.
onTapUp: widget.onEventBackgroundTap != null
? (details) {
...
}
: null,
This still needs to be done. Otherwise I think we are nearly done? :) I'd seperate the tapping inside the header function to a seperate issue and not include in this pull request. Even though it's related I think I'd create a different issue for semantical reasons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is there a reason you didn't use millisecond precision? That would make the code much cleaner:
final millis = details.localPosition.dy / constraints.maxHeight
* TimeConstants.millisecondsPerDay;
final time = LocalTime.sinceMidnight(Time(milliseconds: millis.floor()));
// Note: I haven't tested this code
Also, users of this package can decide the necessary precision by themselves.
-
Yes, that's legit. That way, we can also drop the
if (widget.onEventBackgroundTap != null)
guard (and that inall_day_events.dart
) as the listener cannot be null when it should be invoked.
By extracting the private helper function, I meant to extract the whole lambda, though. That way, there isn't an additional ≈ 10 lines of logic inside the already nestedbuild
method whose primary purpose is to create the UI. You can simply move the whole lambda content to the helper methods you already created. -
I think we might be talking about different "header" functions. My idea was that the callbacks currently called
onAllDayEventBackgroundTap
andonEventBackgroundTap
can be merged into a single callbackonEventBackgroundTap
. IfisAllDay
is set tofalse
when that callback is invoked, the user tapped somewhere in the part-day content area. IfisAllDay
istrue
, the user tapped in the all-day event area of the header. Sorry for the bad wording :/
Also, I just noticed that theOnCreateEventCallback
-typedef can now be renamed to something likeOnEventBackgroundTapCallback
.
But apart from these (now relatively minor) comments, we're done :)
@@ -55,7 +55,7 @@ class TimetableContent<E extends Event> extends StatelessWidget { | |||
child: MultiDateContent<E>( | |||
controller: controller, | |||
eventBuilder: eventBuilder, | |||
onCreateEvent: onCreateEvent | |||
onEventBackgroundTap: onEventBackgroundTap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onEventBackgroundTap: onEventBackgroundTap | |
onEventBackgroundTap: onEventBackgroundTap, |
Great feedback. The code is much cleaner now.
EG. when tapping where the red arrow points at. Merging two listeners into one eases the usement of the librabry and makes the code much cleaner. I'm still learning so thanks for your awesome feedback so far! Really appreciated. |
Now that everything works as intended and the code looks fine, unless you have anything more you want to add, we can merge this PR! |
I think we are good to go :) Cheers! |
This is now published as part of v0.2.4. Thanks for contributing! |
Thanks for the opportunity @JonasWanke . Hopefully I can contribute some more in the future! |
Closes: #18
I thought I'd issue a pull request at the current state regarding #18.
Background taps are currently recognized across
DateEvents
andAllDayEvents
. Tapping on headers is currently not implemented yet.The pull request adapted the example with a snackbar function.
There are some things on my mind and I'm looking forward to your feedback:
Is the name
onCreateEvent
andonCreateAllDayEvent
really appliceable? Maybe we should change it to somehting likeonBackgroundTap
oronCellTap
?Regarding
DateEvents
I'm not quite sure why when calculating the position of the tapped cell I need to add a+1
here:+2
for the day.I'm not really sure about the calculations at all. The offset issue with the days might be related to wrong rounding? Might also be a conversion problem related to
final startTime = LocalDateTime.dateTime(dateAndTime)
I think? Maybe you could shed some light into this and the calculation at all. Also the time of the giving back object is always23:00:00
eventhough it should be00:00:00